/**
** params = {
**    methodCode:'xxxx',methodId:123,itemId:123,itemName:'xxxx',value:0.0001,args:{"XS":0.1,"xxxx":xx}
**}
* 返回参数 value
*/
//ICP-AES修约
(function calc(params){
    var value = params.value;
    var args = params.args;
    
    if(args === null || args === undefined){
       return value; 
    }
    var argsJson = JSON.parse(args)
    var xs = argsJson.XS;
    var blk = argsJson.BLK;
    var blk_si = argsJson.BLK_SI;
    if(blk === null || blk ===undefined || blk === ''){
        blk = 0
    }
    if(blk_si === null || blk_si ===undefined || blk_si === ''){
        blk_si = 0
    }
    value = value-blk-blk_si
    // throw new Error(xs+'---'+blk)
    if(xs !== null && xs !== undefined && xs !== ''){
        value =value*xs
    }
    // if(params.methodCode == '123123'){
    //     value = params.value
    // }else{
    //     var valueDigits = (params.value.toString().split('.')[1] || '').length
    //     var baseNum = Math.pow(10, valueDigits)
    //     value = (params.value*baseNum+0.001*baseNum)/baseNum
    // }
    value=value.toFixed(6);
    return value;
})(params);

//质谱修约
(function calc(params){
    var value = params.value;
    var args = params.args;
    
    if(args === null || args === undefined){
       return value; 
    }
    var argsJson = JSON.parse(args)
    var xs = argsJson.XS;
    var blk = argsJson.BLK;

    if(blk === null || blk ===undefined || blk === ''){
        blk = 0
    }
    value = value-blk
    // throw new Error(xs+'---'+blk)
    if(xs !== null && xs !== undefined && xs !== ''){
        value =value*xs
    }
    value=value/10000.0;
    value=value.toFixed(7);
    return value;
})(params);